import {isEmpty, isNumber, cloneDeep} from "lodash";


export function isValueExist(value) {
  return isNumber(value) || !isEmpty(value)
}

export function copyByKey(original, target) {
  Object.keys(original).forEach(key => {
    if(!!target[key]) {
      original[key] = cloneDeep(target[key])
    }
  })
}

export function treeFind (tree, func) {
  for (const data of tree) {
    if (func(data)) return data
    if (data.children) {
      const res = treeFind(data.children, func)
      if (res) return res
    }
  }
  return null
}
